﻿<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
        xmlns:NamaAlert="clr-namespace:Co9320"
        Height="400" Width="400"
        MinHeight="160" MinWidth="280"
        Icon="../Icons/application.ico">
    <Window.Title>
        <MultiBinding StringFormat="{}{0}/{1} - ニコ生アラート" >
            <Binding Path="AlertedProgramsCount" />
            <Binding Path="LivePrograms.Count" />
        </MultiBinding>
    </Window.Title>
    <Window.DataContext>
        <NamaAlert:NamaAlertDataContext />
    </Window.DataContext>

    <Window.CommandBindings>
        <CommandBinding Command="{x:Static NamaAlert:MainWindow.AddStationsCommand}" Executed="AddStationsCommand_Executed" CanExecute="ForDataGridRowsCommand_CanExecute" />
        <CommandBinding Command="{x:Static NamaAlert:MainWindow.DeleteStationsCommand}" Executed="DeleteStationsCommand_Executed" CanExecute="ForDataGridRowsCommand_CanExecute" />
        <CommandBinding Command="{x:Static NamaAlert:MainWindow.DeleteKeywordsCommand}" Executed="DeleteKeywordsCommand_Executed" CanExecute="DeleteKeywordsCommand_CanExecute" />
        <CommandBinding Command="{x:Static NamaAlert:MainWindow.OpenUrisCommand}" Executed="OpenUrisCommand_Executed" CanExecute="ForDataGridRowsCommand_CanExecute" />
        <CommandBinding Command="{x:Static NamaAlert:MainWindow.CopyUriCommand}" Executed="CopyUriCommand_Executed" CanExecute="ForOnlyDataGridRowCommand_CanExecute" />
        <CommandBinding Command="{x:Static NamaAlert:MainWindow.ShowAlertSettingsCommand}" Executed="ShowAlertSettingsCommand_Executed" />
        <CommandBinding Command="{x:Static NamaAlert:MainWindow.FilterProgramsCommand}" Executed="FilterProgramsCommand_Executed" />
        <CommandBinding Command="{x:Static NamaAlert:MainWindow.SetTimerCommand}" Executed="SetTimerCommand_Executed" />
        <CommandBinding Command="{x:Static NamaAlert:MainWindow.OpenNiconamaCommentViewerCommand}" Executed="OpenNiconamaCommentViewerCommand_Executed" CanExecute="ForDataGridRowsCommand_CanExecute" />

        
    </Window.CommandBindings>


    <Window.Resources>
        <NamaAlert:MemberOnlyConverter x:Key="MemberOnlyConverter"/>
        <NamaAlert:FaceConverter x:Key="FaceConverter"/>
        <NamaAlert:OnAirConverter x:Key="OnAirConverter"/>
        <NamaAlert:RecentAirdateConverter x:Key="RecentAirdateConverter"/>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

        <ContextMenu x:Key="ColumnHeaderContextMenu">
            <MenuItem Header="未実装" />
        </ContextMenu>

        <ContextMenu x:Key="ProgramColumnHeaderContextMenu">
            <MenuItem Header="{Binding ElementName=ProgramDataGrid, Path=Name}" IsChecked="{Binding ElementName=ProgramTitleColumn, Path=Visibility, Converter={StaticResource BooleanToVisibilityConverter}}" />
        </ContextMenu>
        
        <ContextMenu x:Key="ProgramsRowContextMenu">
            <MenuItem Header="生放送のページへ移動" Command="{x:Static NamaAlert:MainWindow.OpenUrisCommand}" CommandParameter="program" />
            <MenuItem Header="URLをコピー" Command="{x:Static NamaAlert:MainWindow.CopyUriCommand}" CommandParameter="program" />
            <Separator />
            <MenuItem Header="通知対象に追加" Command="{x:Static NamaAlert:MainWindow.AddStationsCommand}" />
            <Separator 
                Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Settings.General.EnableNiconamaCommentViewer, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}"/>
            <MenuItem Header="NiconamaCommentViewer で開く" 
                      Command="{x:Static NamaAlert:MainWindow.OpenNiconamaCommentViewerCommand}"  
                      Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Settings.General.EnableNiconamaCommentViewer, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}" />
        </ContextMenu>

        <ContextMenu x:Key="StationsRowContextMenu">
            <MenuItem Header="生放送のページへ移動" Command="{x:Static NamaAlert:MainWindow.OpenUrisCommand}" IsEnabled="{Binding Path=IsOnAir}" CommandParameter="liveprogram" />
            <MenuItem Header="放送局のページへ移動" Command="{x:Static NamaAlert:MainWindow.OpenUrisCommand}" CommandParameter="station" />
            <MenuItem Header="生放送のURLをコピー" Command="{x:Static NamaAlert:MainWindow.CopyUriCommand}" IsEnabled="{Binding Path=IsOnAir}" CommandParameter="liveprogram" />
            <MenuItem Header="放送局のURLをコピー" Command="{x:Static NamaAlert:MainWindow.CopyUriCommand}" CommandParameter="station" />
            <Separator />
            <MenuItem Header="削除" Command="{x:Static NamaAlert:MainWindow.DeleteStationsCommand}" />
        </ContextMenu>

        <ContextMenu x:Key="KeywordsRowContextMenu">
            <MenuItem Header="削除" Command="{x:Static NamaAlert:MainWindow.DeleteKeywordsCommand}" />
        </ContextMenu>
        
        <Style x:Key="DefaultCellStyle" TargetType="{x:Type dg:DataGridCell}">
            <Setter Property="TextBlock.VerticalAlignment" Value="Stretch" />
            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="DataGridCell_PreviewMouseLeftButtonDown"></EventSetter>
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type dg:DataGridCell}">
                        <Border Padding="2"  Background="{TemplateBinding Background}" 
                              BorderBrush="{TemplateBinding BorderBrush}"  
                              BorderThickness="{TemplateBinding BorderThickness}" 
                              SnapsToDevicePixels="True">
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        
        <Style x:Key="DefaultColumnHeaderStyle" TargetType="{x:Type dg:DataGridColumnHeader}">
            <Setter Property="ContextMenu" Value="{StaticResource ColumnHeaderContextMenu}" />
        </Style>
        <Style x:Key="ImageButtonBaseStyle" TargetType="{x:Type ButtonBase}">
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <ContentPresenter Name="Presenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" RenderTransformOrigin="0.5,0.5"/>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="RenderTransform" TargetName="Presenter">
                                    <Setter.Value>
                                        <TranslateTransform X="1" Y="1"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ImageButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource ImageButtonBaseStyle}"/>

        <Style x:Key="DropDownButtonBaseStyle" TargetType="{x:Type NamaAlert:DropDownButton}">
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type NamaAlert:DropDownButton}">
                        <ContentPresenter Name="Presenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" RenderTransformOrigin="0.5,0.5"/>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="RenderTransform" TargetName="Presenter">
                                    <Setter.Value>
                                        <TranslateTransform X="1" Y="1"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="DropDownButtonStyle" TargetType="{x:Type NamaAlert:DropDownButton}" BasedOn="{StaticResource DropDownButtonBaseStyle}"/>

        <Style x:Key="DataGridRowStyle" TargetType="dg:DataGridRow">
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Background" Value="White" />
            <Style.Triggers>
                <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                    <Setter Property="Background" Value="#F3F7FB" />
                </Trigger>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#504B95E5" />
                </Trigger>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="#4B95E5" />
                </Trigger>
            </Style.Triggers>

        </Style>

        <Style TargetType="dg:DataGridRow" x:Key="ProgramRowStyle" BasedOn="{StaticResource DataGridRowStyle}">
            <Setter Property="ContextMenu" Value="{StaticResource ProgramsRowContextMenu}" />
        </Style>

        <Style TargetType="dg:DataGridRow" x:Key="StationRowStyle" BasedOn="{StaticResource DataGridRowStyle}">
            <Setter Property="ContextMenu" Value="{StaticResource StationsRowContextMenu}" />
        </Style>

        <Style TargetType="dg:DataGridRow" x:Key="KeywordRowStyle" BasedOn="{StaticResource DataGridRowStyle}">
            <Setter Property="ContextMenu" Value="{StaticResource KeywordsRowContextMenu}" />
        </Style>

    </Window.Resources>


    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="24"  />
        </Grid.RowDefinitions>
        <TabControl>
            <TabItem Height="23">
                <TabItem.Header >
                    <TextBlock>
                        <TextBlock.Text>
                            <MultiBinding StringFormat="{}生放送一覧({0}/{1})">
                                <Binding Path="AlertedProgramsCount" />
                                <Binding Path="LivePrograms.Count" />
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                </TabItem.Header>
                
                <TabItem.InputBindings>
                    <KeyBinding Command="{x:Static NamaAlert:MainWindow.FilterProgramsCommand}" Key="F" Modifiers="Control" />
                </TabItem.InputBindings>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="32" />
                    </Grid.RowDefinitions>
                    
                    <NamaAlert:DataGridListView
                        x:Name="ProgramDataGrid"
                        RowStyle="{StaticResource ProgramRowStyle}"
                        IsReadOnly="True"
                        CanUserAddRows="False"
                        CellStyle="{StaticResource DefaultCellStyle}"
                        AlternationCount="2"
                        
                        RowDetailsVisibilityMode="VisibleWhenSelected"
                        RowDetailsVisibilityChanged="ProgramDataGrid_RowDetailsVisibilityChanged"
                        MouseDoubleClick="ProgramDataGird_MouseDoubleClick">
                        <NamaAlert:DataGridListView.RowDetailsTemplate>
                            <DataTemplate DataType="{x:Type NamaAlert:LiveProgram}">
                                <Grid HorizontalAlignment="Stretch" Background="White">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="56" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Image Margin="4" Width="48" Height="48" 
                                           Source="{Binding Path=Station.Icon, Mode=OneWay}"
                                           VerticalAlignment="Top"
                                           />
                                    <ScrollViewer Grid.Column="1"
                                                  HorizontalAlignment="Stretch"
                                                  CanContentScroll="True"
                                                  VerticalScrollBarVisibility="Auto"
                                                  Height="56"
                                                  >

                                        <TextBox Text="{Binding Path=Content, Mode=OneWay}"
                                                 IsReadOnly="True"
                                                 TextWrapping="Wrap"
                                                 BorderThickness="0"
                                                 HorizontalAlignment="Stretch"
                                                    />
                                    </ScrollViewer>
                                </Grid>
                            </DataTemplate>
                        </NamaAlert:DataGridListView.RowDetailsTemplate>
                        
                        <NamaAlert:DataGridListView.ColumnHeaderStyle>
                            <Style TargetType="{x:Type dg:DataGridColumnHeader}">
                                <Setter Property="ContextMenu" Value="{StaticResource ProgramColumnHeaderContextMenu}" />
                            </Style>
                        </NamaAlert:DataGridListView.ColumnHeaderStyle>
                        
                        
                        
                        <dg:DataGrid.Columns>
                            <dg:DataGridTextColumn 
                                Header="タイトル" 
                                x:Name="ProgramTitleColumn"
                                Width="150"
                                Binding="{Binding Path=Title, Mode=OneWay}"
                                Visibility="Visible"/>
                            <dg:DataGridTextColumn 
                                Header="放送局" 
                                Width="150"
                                Binding="{Binding Path=Station.Name, Mode=OneWay}" />
                            <dg:DataGridTextColumn 
                                Header="放送者" 
                                
                                Width="100"
                                Binding="{Binding Path=Caster, Mode=OneWay}" />
                            <dg:DataGridTextColumn 
                                Header="開始時間" 
                                Width="70"
                                Binding="{Binding Path=StartDateTime, StringFormat=HH:mm, Mode=OneWay}" />
                            <dg:DataGridTextColumn 
                                Header="来場者数" 
                                Width="50"
                                Binding="{Binding Path=VisitorCount, Mode=OneWay}" />
                            <dg:DataGridTextColumn 
                                Header="コメ数" 
                                Width="50"
                                
                                Binding="{Binding Path=CommentCount, Mode=OneWay}" />
            
                            <dg:DataGridTextColumn 
                                Header="公開" 
                                Width="50"
                                Binding="{Binding Path=IsMemberOnly, Converter={StaticResource MemberOnlyConverter}, Mode=OneWay}"
                                 />

                            <dg:DataGridTextColumn 
                                Header="タグ" 
                                Width="80"
                                Binding="{Binding Path=Category, Mode=OneWay}" />
                            <dg:DataGridTextColumn 
                                Header="顔出し" 
                                Width="50"
                                Binding="{Binding Path=IsFace, Converter={StaticResource FaceConverter}, Mode=OneWay}" />

                            <dg:DataGridTemplateColumn 
                                                       Width="24"
                                                       SortMemberPath="IsAlerted"
                                                       >
                                <dg:DataGridTemplateColumn.Header>
                                    <Image Source="../Images/shadow/bell.png" Stretch="None" ToolTipService.ToolTip="通知対象" Width="16" Height="16" />
                                </dg:DataGridTemplateColumn.Header>
                                <dg:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Image Source="../Images/shadow/bell.png" 
                                               VerticalAlignment="Center"
                                               Visibility="{Binding Path=IsAlerted, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}"
                                               Width="16" Height="16" Stretch="None" />
                                    </DataTemplate>
                                </dg:DataGridTemplateColumn.CellTemplate>
                            </dg:DataGridTemplateColumn>

               
                        </dg:DataGrid.Columns>

                    </NamaAlert:DataGridListView>
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="64" />
                        </Grid.ColumnDefinitions>
                        <StackPanel Orientation="Horizontal" Margin="0 6 0 0" HorizontalAlignment="Left">
                            <Canvas>
                                <TextBox Width="150" Height="24" Margin="0 0 0 0" VerticalAlignment="Center"
                                         TextChanged="FilterTextBox_TextChanged"
                                         Name="FilterTextBox"
                                         VerticalContentAlignment="Center">
                                    <TextBox.Style>
                                        <Style TargetType="TextBox">
                                            <Style.Triggers>
                                                <MultiDataTrigger>
                                                    <MultiDataTrigger.Conditions>
                                                        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text.Length}" Value="0"/>
                                                        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsFocused}" Value="False"/>
                                                    </MultiDataTrigger.Conditions>
                                                    <Setter Property="Background">
                                                        <Setter.Value>
                                                            <VisualBrush Stretch="None" AlignmentX="Left">
                                                                <VisualBrush.Visual>
                                                                    <TextBlock Foreground="Gray" FontSize="12" Text="絞り込み" Margin="3" />
                                                                </VisualBrush.Visual>
                                                            </VisualBrush>
                                                        </Setter.Value>
                                                    </Setter>
                                                </MultiDataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBox.Style>
                                </TextBox>
                            </Canvas>
                        </StackPanel>
                        <StackPanel Grid.Column="1" Margin="0 6 0 0" Orientation="Horizontal" HorizontalAlignment="Right">
                        </StackPanel>

                    </Grid>
                </Grid>
            </TabItem>
            <TabItem Name="StationTabItem" >
                <TabItem.Header >
                    <TextBlock>
                        <TextBlock.Text>
                            <MultiBinding StringFormat="{}放送局({0}/{1})">
                                <Binding Path="AlertedStationsCount" />
                                <Binding Path="Stations.Count" />
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                </TabItem.Header>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="32" />
                    </Grid.RowDefinitions>
                    <NamaAlert:DataGridListView
                        x:Name="StationDataGrid"
                        AlternationCount="2"
                        RowStyle="{StaticResource StationRowStyle}"
                        CellStyle="{StaticResource DefaultCellStyle}"
                        
                        ColumnHeaderStyle="{StaticResource DefaultColumnHeaderStyle}"
                        CanUserAddRows="False"
                        MouseDoubleClick="StationDataGird_MouseDoubleClick">
                        <NamaAlert:DataGridListView.InputBindings>
                            <KeyBinding Command="{x:Static NamaAlert:MainWindow.DeleteStationsCommand}" Key="Delete" />
                        </NamaAlert:DataGridListView.InputBindings>

                        <dg:DataGrid.Columns>
                           
                            <dg:DataGridTextColumn 
                                Header="On Air" 
                                Width="50"
                                IsReadOnly="True"
                                Binding="{Binding Path=IsOnAir, Converter={StaticResource OnAirConverter}}" />
                            <dg:DataGridTextColumn 
                                Header="コミュニティ＆チャンネル" 
                                Width="120"
                                IsReadOnly="True"
                                Binding="{Binding Path=Name}" />
                            <dg:DataGridTextColumn 
                                Header="最近の放送日時" 
                                Width="100"
                                IsReadOnly="True"
                                Binding="{Binding Path=RecentAirdate, Converter={StaticResource RecentAirdateConverter}}" />
                            <dg:DataGridTextColumn 
                                Header="最近の番組名" 
                                Width="120"
                                IsReadOnly="True"
                                Binding="{Binding Path=RecentTitle}" />

                            <dg:DataGridCheckBoxColumn 
                                
                                Binding="{Binding Path=AlertByWindow, Mode=TwoWay}">
                                <dg:DataGridCheckBoxColumn.Header>
                                    <Image Source="../Images/shadow/card_address.png" Stretch="None" ToolTipService.ToolTip="通知ウィンドウ" Width="16" Height="16" />
                                </dg:DataGridCheckBoxColumn.Header>
                            </dg:DataGridCheckBoxColumn>
                            <dg:DataGridCheckBoxColumn 
                                Binding="{Binding Path=AlertByBalloon, Mode=TwoWay}">
                                <dg:DataGridCheckBoxColumn.Header>
                                    <Image Source="../Images/shadow/balloon_left.png" Stretch="None" ToolTipService.ToolTip="バルーン" Width="16" Height="16" />
                                </dg:DataGridCheckBoxColumn.Header>
                            </dg:DataGridCheckBoxColumn>
                            <dg:DataGridCheckBoxColumn 
                                Binding="{Binding Path=AlertByBrowser, Mode=TwoWay}">
                                <dg:DataGridCheckBoxColumn.Header>
                                    <Image Source="../Images/shadow/application__arrow.png" Stretch="None" ToolTipService.ToolTip="Webブラウザー" Width="16" Height="16" />
                                </dg:DataGridCheckBoxColumn.Header>
                            </dg:DataGridCheckBoxColumn>
                            <dg:DataGridCheckBoxColumn 
                                Binding="{Binding Path=AlertByMail, Mode=TwoWay}">
                                <dg:DataGridCheckBoxColumn.Header>
                                    <Image Source="../Images/shadow/mail.png" Stretch="None" ToolTipService.ToolTip="メール" Width="16" Height="16" />
                                </dg:DataGridCheckBoxColumn.Header>
                            </dg:DataGridCheckBoxColumn>
                            <dg:DataGridCheckBoxColumn 
                                Binding="{Binding Path=AlertBySound, Mode=TwoWay}">
                                <dg:DataGridCheckBoxColumn.Header>
                                    <Image Source="../Images/shadow/music.png" Stretch="None" ToolTipService.ToolTip="サウンド" Width="16" Height="16"   />
                                </dg:DataGridCheckBoxColumn.Header>
                            </dg:DataGridCheckBoxColumn>
                        </dg:DataGrid.Columns>

                    </NamaAlert:DataGridListView>

                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="64" />
                        </Grid.ColumnDefinitions>
                        <StackPanel Orientation="Horizontal" Margin="0 6 0 0" HorizontalAlignment="Left">
                            <Canvas>
                                <TextBox Width="160" Height="24" VerticalAlignment="Center"
                                     TextChanged="StationTextBox_TextChanged"
                                     KeyDown="StationTextBox_KeyDown"
                                     Name="StationTextBox"
                                     VerticalContentAlignment="Center">
                                    <TextBox.Style>
                                        <Style TargetType="TextBox">
                                            <Style.Triggers>
                                                <MultiDataTrigger>
                                                    <MultiDataTrigger.Conditions>
                                                        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text.Length}" Value="0"/>
                                                        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsFocused}" Value="False"/>
                                                    </MultiDataTrigger.Conditions>
                                                    <Setter Property="Background">
                                                        <Setter.Value>
                                                            <VisualBrush Stretch="None" AlignmentX="Left">
                                                                <VisualBrush.Visual>
                                                                    <TextBlock Foreground="Gray" FontSize="12" Text="放送局追加 (例: co9320)" />
                                                                </VisualBrush.Visual>
                                                            </VisualBrush>
                                                        </Setter.Value>
                                                    </Setter>
                                                </MultiDataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBox.Style>
                                </TextBox>
                                <Button
                                    Canvas.Left="138" Canvas.Top="5"
                                    Padding="0" Style="{StaticResource ImageButtonStyle}" Margin="5 0 0 0"
                                    Click="AddStationButton_Click">
                                    <StackPanel Orientation="Horizontal" >
                                        <Image Margin="0" Source="../Images/shadow/plus.png" Width="13" Height="13" />
                                        
                                        <!--<TextBlock Text="" VerticalAlignment="Center" Name="SearchedStationNameTextBox" />
                                        <TextBlock Text="追加" VerticalAlignment="Center" Margin="5 0 0 0" />-->
                                    </StackPanel>
                                </Button>

                            </Canvas>
                        </StackPanel>
                        <!--<StackPanel Grid.Column="1" Margin="0 6 0 0" Orientation="Horizontal" HorizontalAlignment="Right">
                            <Button Padding="0" ToolTip="設定"
                                    Style="{StaticResource ImageButtonStyle}"
                                    Command="{x:Static NamaAlert:MainWindow.ShowAlertSettingsCommand}" CommandParameter="station">
                                <Image Margin="0" Source="../Images/settings.png" Stretch="None" />
                            </Button>
                        </StackPanel>-->

                    </Grid>
                </Grid>
            </TabItem>
            <TabItem Header="キーワード" x:Name="KeywordTabItem">
                <Grid>
                    <NamaAlert:DataGridListView
                        x:Name="KeywordDataGrid"
                        ItemsSource="{Binding Path=Keywords}"
                        AlternationCount="2"
                        ColumnHeaderStyle="{StaticResource DefaultColumnHeaderStyle}"
                        CellStyle="{StaticResource DefaultCellStyle}"
                        CanUserAddRows="True"
                        RowStyle="{StaticResource KeywordRowStyle}"
                        >

                        <dg:DataGrid.Columns>
                            <dg:DataGridTextColumn 
                                Header="タイトル"          
                                Width="100"
                                Binding="{Binding Path=Title, Mode=TwoWay}" />
                            <dg:DataGridTextColumn 
                                Header="放送局名" 
                                Width="100"
                                Binding="{Binding Path=Station, Mode=TwoWay}" />
                            <dg:DataGridTextColumn 
                                Header="詳細" 
                                Width="100"
                                Binding="{Binding Path=Content, Mode=TwoWay}" />
                            <dg:DataGridTextColumn 
                                Header="放送者" 
                                Width="100"
                                Binding="{Binding Path=Caster, Mode=TwoWay}" />
                            <dg:DataGridCheckBoxColumn 
                                Binding="{Binding Path=AlertByWindow, Mode=TwoWay}">
                                <dg:DataGridCheckBoxColumn.Header>
                                    <Image Source="../Images/shadow/card_address.png" Stretch="None" ToolTipService.ToolTip="通知ウィンドウ" />
                                </dg:DataGridCheckBoxColumn.Header>
                            </dg:DataGridCheckBoxColumn>
                            <dg:DataGridCheckBoxColumn 
                                Binding="{Binding Path=AlertByBalloon, Mode=TwoWay}">
                                <dg:DataGridCheckBoxColumn.Header>
                                    <Image Source="../Images/shadow/balloon_left.png" Stretch="None" ToolTipService.ToolTip="バルーン" />
                                </dg:DataGridCheckBoxColumn.Header>
                            </dg:DataGridCheckBoxColumn>
                            <dg:DataGridCheckBoxColumn 
                                Binding="{Binding Path=AlertByBrowser, Mode=TwoWay}">
                                <dg:DataGridCheckBoxColumn.Header>
                                    <Image Source="../Images/shadow/application__arrow.png" Stretch="None" ToolTipService.ToolTip="Webブラウザー" />
                                </dg:DataGridCheckBoxColumn.Header>
                            </dg:DataGridCheckBoxColumn>
                            <dg:DataGridCheckBoxColumn 
                                Binding="{Binding Path=AlertByMail, Mode=TwoWay}">
                                <dg:DataGridCheckBoxColumn.Header>
                                    <Image Source="../Images/shadow/mail.png" Stretch="None" ToolTipService.ToolTip="メール" />
                                </dg:DataGridCheckBoxColumn.Header>
                            </dg:DataGridCheckBoxColumn>
                            <dg:DataGridCheckBoxColumn 
                                Binding="{Binding Path=AlertBySound, Mode=TwoWay}">
                                <dg:DataGridCheckBoxColumn.Header>
                                    <Image Source="../Images/shadow/music.png" Stretch="None" ToolTipService.ToolTip="サウンド" />
                                </dg:DataGridCheckBoxColumn.Header>
                            </dg:DataGridCheckBoxColumn>
                        </dg:DataGrid.Columns>

                    </NamaAlert:DataGridListView>
                </Grid>
            </TabItem>

        </TabControl>

        <StatusBar Grid.Row="1" Name="MainStatusBar">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="100"/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem>
                <TextBlock Text="{Binding Path=StatusBarText}" VerticalAlignment="Center">
                    <TextBlock.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="タイマー">
                                <MenuItem Header="1分" Command="{x:Static NamaAlert:MainWindow.SetTimerCommand}" CommandParameter="1" />
                                <MenuItem Header="3分" Command="{x:Static NamaAlert:MainWindow.SetTimerCommand}" CommandParameter="3" />
                                <MenuItem Header="5分" Command="{x:Static NamaAlert:MainWindow.SetTimerCommand}" CommandParameter="5" />
                                <Separator />
                                <MenuItem Header="オフ" IsEnabled="{Binding Path=RunningTimer}"  Command="{x:Static NamaAlert:MainWindow.SetTimerCommand}" CommandParameter="0" />
                            </MenuItem>
                        </ContextMenu>
                    </TextBlock.ContextMenu>
                </TextBlock>
            </StatusBarItem>
            <StatusBarItem Grid.Column="1" HorizontalAlignment="Right">
            </StatusBarItem>
        </StatusBar>

        
        <NamaAlert:DropDownButton Grid.Column="1" HorizontalAlignment="Right"
                                  VerticalAlignment="Top"
                                  Margin="5"
                                  Style="{StaticResource DropDownButtonStyle}">
            <NamaAlert:DropDownButton.Content>
                <Image Source="../Images/shadow/gear.png" Stretch="None" ToolTipService.ToolTip="設定" />
            </NamaAlert:DropDownButton.Content>
            <NamaAlert:DropDownButton.DropDown>
                <ContextMenu ContextMenuOpening="ContextMenu_ContextMenuOpening">
                    <MenuItem Header="設定..." Command="{x:Static NamaAlert:MainWindow.ShowAlertSettingsCommand}" />
                    <MenuItem Header="設定保存場所を開く" Click="MenuItem_Click" />
                    <!--<MenuItem Header="スタートアップに登録" Click="RegisterStartupMenuItem_Click" x:Name="RegisterStartupMenuItem" />-->
                    <!--<Separator />
                    <MenuItem Header="設定（未実装）..." Click="GeneralSettingsButton_Click"/>-->
                </ContextMenu>
            </NamaAlert:DropDownButton.DropDown>
        </NamaAlert:DropDownButton>
    </Grid>
</Window>
